# Maintainer: Jürgen Pfeifer <juergen@familiepfeifer.de>
# Contributor: Tim S <stahta01@gmail.com>

# Pathnames in this project can get quite long, so at least on Windows
# I recommend to use a short BUILDDIR setting to avoid problems
#

_realname=xmlada
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=2020
pkgrel=1

_xmlada_commit="c16f24ebf752b7d75dfdd0eaa7dd501a08a31256"
_xmlada_extract_dir="AdaCore-xmlada-c16f24e"

pkgdesc="A full XML suite for Ada (mingw-w64)"
arch=('any')
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-gpl")
url="https://libre.adacore.com/libre/tools/xmlada/"
license=('GPL3')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc-ada"
             "${MINGW_PACKAGE_PREFIX}-gprbuild-bootstrap-git")
depends=()
source=("xmlada.tar.gz::https://api.github.com/repos/AdaCore/xmlada/tarball/${_xmlada_commit}")
sha256sums=('12139d8c3d511b516f9dcf68ee76a70f2dc52031d379e9e4942aa84346974751')
options=('strip')

build() {
  cd ${srcdir}/${_xmlada_extract_dir}
  ./configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-shared

  make
}

package() {
  mkdir -p ${pkgdir}${MINGW_PREFIX}/include/xmlada
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/xmlada/static
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/xmlada/relocatable
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/gnat/xmlada

  cd ${srcdir}/${_xmlada_extract_dir}
  make -j1 prefix=${pkgdir}${MINGW_PREFIX} INSTALL=cp install

  rm -rf ${pkgdir}${MINGW_PREFIX}/share/examples
  rm -rf ${pkgdir}${MINGW_PREFIX}/share/doc

  # Copy License Files
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname
  cp -pf ${srcdir}/${_xmlada_extract_dir}/COPYING* \
    ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}
}
